<?php require_once(dirname(__FILE__).'/inc/config.inc.php');IsModelPriv('diyfield_list'); ?>
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<meta name="viewport" content="width=device-width,minimum-scale=1.0,maximum-scale=1.0,initial-scale=1.0,user-scalable=no" />
<meta name="apple-mobile-web-app-capable" content="yes" />
<title>添加扩展字段</title>
<link href="templates/css/style.css?c=1" rel="stylesheet" type="text/css" />
<script type="text/javascript" charset="utf-8" src="templates/js/jquery-1.11.2.min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/jquery.nicescroll.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/Validform_v5.3.2_min.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/laymain.js"></script>
<script type="text/javascript" charset="utf-8" src="templates/js/common.js"></script>
<script type="text/javascript">
   $(function () {
	   $("#infotype").change(function(){
		var v = $(this).val();
		$.ajax({
			url : "ajax_do.php?action=diyfield&type="+v,
			type:'get',
			dataType:'html',
			beforeSend:function(){},
			success:function(data, textStatus, xmlHttp){
				if(data != ''){
					$("#purviewList").html(data);
				}
			}
		});
	});
	 $("#fieldtype").change(function(){
		var v = $(this).val();
		$.ajax({
			url : "ajax_do.php?action=fieldtype&type="+v,
			type:'get',
			dataType:'html',
			beforeSend:function(){},
			success:function(data, textStatus, xmlHttp){
				if(data != ''){
					$("#expand").html(data);
				}
			}
		});
	});
        //初始化表单验证
        $("#form").initValidform();
    });

</script>
</head>

<body class="mainbody">
<form name="form" id="form" method="post" action="diyfield_save.php" >
<!--导航栏-->
<div class="location">
  <a href="javascript:history.back(-1);" class="back"><i></i><span>返回列表页</span></a>
  <a href="home.php" class="home"><i></i><span>首页</span></a>
  <i class="arrow"></i>
  <a href="diyfield.php"><span>扩展字段管理</span></a>
  <i class="arrow"></i>
  <span>添加扩展字段</span>
  <a href="javascript:location.reload();" class="reload">刷新</a> 
</div>
<div class="line10"></div>
<!--/导航栏-->

<!--内容-->
<div id="floatHead" class="content-tab-wrap">
  <div class="content-tab">
    <div class="content-tab-ul-wrap">
      <ul>
        <li><a class="selected" href="javascript:;">添加扩展字段</a></li>
      </ul>
    </div>
  </div>
</div>

<div class="tab-content">
  <dl>
    <dt>所属模型</dt>
    <dd>
      <div class="rule-single-select">
        <select name="infotype" id="infotype" datatype="n1-16" sucmsg=" " errormsg="请选择模型！">
				<?php
				$model = array('0'=>'单页','1'=>'列表','4'=>'商品');
				foreach($model as $k=>$v)
				{
					echo '<option value="'.$k.'">'.$v.'</option>';
				}
				
				//循环自定义模型
				$dosql->Execute("SELECT * FROM `#@__diymodel` ORDER BY id ASC");
				while($row = $dosql->GetArray())
				{
					echo '<option value="'.$row['id'].'">'.$row['modeltitle'].'</option>';
				}
				?>
		</select>
      </div>
    </dd>
  </dl>
  <dl>
    <dt>所属栏目</dt>
    <dd>
     	<div class="rule-multi-porp" id="purviewList">
          
		<?php
			echo '<span>';
			$dosql->Execute("SELECT * FROM `#@__infoclass` WHERE `infotype`='0' ORDER BY orderid ASC");
			while($row = $dosql->GetArray())
			{
				echo '<input type="checkbox" name="classid[]" id="classid[]'.$row['id'].'" value="'.$row['id'].'" /><label for="classid[]'.$row['id'].'">'.$row['classname'].'</label>';
			}
			echo  '</span>';
			?>
			</div>
    </dd>
  </dl>
		<dl>
			<dt>字段类型</dt>
			<dd>
			<div class="rule-single-select"> 
			<select name="fieldtype" id="fieldtype" datatype="*" errormsg="请选择字段类型！" sucmsg=" ">
				<option selected="selected" value="">请选择字段类型...</option>
				<option value="varchar">单行文本</option>
				<option value="text">多行文本</option>
				<option value="mediumtext">编辑器</option>
				<option value="datetime">日期时间</option>
				<option value="number">数字</option>
				<option value="checkbox">多选菜单</option>
				<option value="radio">单选菜单</option>
				<option value="select">下拉菜单</option>
				<option value="file">单个附件[上传]</option>
				<option value="fileall">多个附件[上传]</option>
			</select>
			</div>

			</dd>
		</dl>		
		  <dl>
			<dt>字段标示</dt>
			<dd>
			<input type="text" name="fieldname" id="fieldname" class="input" datatype="/^[^_][a-zA-Z\-\_]{0,48}[^_]$/" sucmsg="" errormsg="仅能字母开头，不能以下划线结尾 2-50位" ajaxurl="ajax_do.php?action=diyfieldname"  />
			  <span class="Validform_checktip">*字母、下划线，不可修改</span>
			</dd>
		  </dl> 
		  <dl>
			<dt>字段标题</dt>
			<dd>
				<input type="text" name="fieldtitle" id="fieldtitle" class="input"  datatype="*" />
			  <span class="Validform_checktip">*例如：文章标题</span>
			</dd>
		  </dl>	
			<dl>
			<dt>字段提示</dt>
			<dd>
				<input type="text" name="fielddesc" id="fielddesc" class="input normal" />
			</dd>
		  </dl>	
		  <div id="expand">

		  </div>   
		  <dl>
			<dt>校验正则</dt>
			<dd>
				<input type="text" name="fieldcheck" id="fieldcheck" class="input normal" />
			  <span class="Validform_checktip">*不需校验数据请留空</span>
			</dd>
		  </dl> 
		  <dl>
			<dt>未通过提示</dt>
			<dd>
			<textarea name="fieldcback" rows="2" cols="20" id="fieldcback" class="input"></textarea>

			  <span class="Validform_checktip">*字段的默认字符，可为空</span>
			</dd>
		  </dl> 
		     <dl>
    <dt>排列排序</dt>
    <dd>
     <input type="text" name="orderid" id="orderid" class="input small" value="<?php echo GetOrderID('#@__diyfield'); ?>" />
    </dd>
  </dl>
		   <dl>
    <dt>审　核</dt>
    <dd>
      <div class="rule-multi-radio">
        <span id="checkinfo"><input id="checkinfo_1" type="radio" name="checkinfo" value="true" checked="checked" /><label for="checkinfo_1">启用</label>
		<input id="checkinfo_2" type="radio" name="checkinfo" value="false" /><label for="checkinfo_2">禁用</label>
		</span>
      </div>
    </dd>
  </dl>
	
</div>
<!--/内容-->

<!--工具栏-->
<div class="page-footer">
  <div class="btn-wrap">
  <input type="submit" name="btnSubmit" value="提交保存" id="btnSubmit" class="btn" />
    <input name="btnReturn" type="button" value="返回上一页" class="btn yellow" onclick="javascript:history.back(-1);" />
	<input type="hidden" name="action" id="action" value="add" />
  </div>
</div>
<!--/工具栏-->

</form>
</body>
</html>